package com.chenjiajin.controller;

import com.chenjiajin.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;

@Slf4j
@RestController
public class LogDemoController {


    @Autowired
    private TestService service;

    @RequestMapping("/aop")
    public String aop(String test) {
        System.out.println("这是执行方法");
        return "success";
    }




    @RequestMapping("/value")
    public String value(String test) {
        service.value();
        return "success";
    }


    @RequestMapping("/log")
    public String log(HttpServletRequest request) {
        service.log(request);
        return "success";
    }



    @RequestMapping("/aop2")  // http://localhost/aop2
    public void aop2() {
        log.trace("time: {}", LocalDate.now());
        log.debug("time: {}", LocalDate.now());
        log.info("time: {}", LocalDate.now());
        log.warn("time: {}", LocalDate.now());
        log.error("time: {}", LocalDate.now());
    }



}